﻿namespace WMS6.Web.Analytics
{
    using System;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.UserControls;

    public class WorkClassRptQuery : BasePage
    {
        protected Button btnSearch;
        protected DropDownList ddlDocTypeOper;
        protected DropDownList ddlForkliftDriverOper;
        protected DropDownList ddlIsHoliday;
        protected DropDownList ddlIsHolidayOper;
        protected DropDownList ddlWorkClassIDOper;
        protected DropDownList ddlWorkType;
        protected DropDownList ddlWorkTypeOper;
        protected HtmlForm F15630;
        protected HtmlInputHidden hdnActionID;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlHead Head1;
        protected Label lblDocType;
        protected Label lblEndDate;
        protected Label lblForkliftDriver;
        protected Label lblIsHoliday;
        protected Label lblQuery;
        protected Label lblStartDate;
        protected Label lblWorkClassID;
        protected Label lblWorkType;
        protected MultipleSelectControl MSCDocType;
        protected HtmlLink mycss;
        protected TextBox txtEndDate;
        protected TextBox txtForkliftDriver;
        protected TextBox txtStartDate;
        protected TextBox txtWorkClassID;

        protected void btnList_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("WorkClassRptList.aspx?action={0}&from=list", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            base.Server.Transfer(string.Format("WorkClassRptList.aspx?action={0}", base.UrlEncode(this.hdnActionID.Value.Trim())), false);
        }

        private void LoadData()
        {
            base.InitQueryDDL(this.ddlWorkClassIDOper, 0);
            base.InitQueryDDL(this.ddlForkliftDriverOper, 0);
            base.InitQueryDDL(this.ddlDocTypeOper, 0);
            base.InitQueryDDL(this.ddlWorkTypeOper, 0);
            base.InitQueryDDL(this.ddlIsHolidayOper, 0);
            this.ddlDocTypeOper.SelectedValue = "One Of";
            base.BindData2DDLBySysCode(this.ddlWorkType, "WorkType");
            base.BindData2DDLBySysCode(this.MSCDocType, "BillingOrderType");
            this.ddlWorkType.Items.Insert(0, "");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
            }
        }

        public string DocType
        {
            get
            {
                if (!string.IsNullOrEmpty(this.MSCDocType.ReturnValue))
                {
                    return base.GetParamsString(this.MSCDocType.ReturnValue, this.ddlDocTypeOper.SelectedValue);
                }
                return "";
            }
        }

        public string EndDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
                {
                    return (Convert.ToDateTime(this.txtEndDate.Text).ToString("yyyy-MM-dd") + " 23:59:59");
                }
                return "";
            }
        }

        public string ForkliftDriver
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtForkliftDriver.Text.Trim()))
                {
                    return base.GetParamsString(this.txtForkliftDriver.Text.Trim(), this.ddlForkliftDriverOper.SelectedValue);
                }
                return "";
            }
        }

        public string IsHoliday
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlIsHoliday.SelectedValue))
                {
                    return base.GetParamsString(this.ddlIsHoliday.SelectedValue, this.ddlIsHolidayOper.SelectedValue);
                }
                return "";
            }
        }

        public string StartDate
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim()))
                {
                    return (Convert.ToDateTime(this.txtStartDate.Text).ToString("yyyy-MM-dd") + " 00:00:00");
                }
                return "";
            }
        }

        public string WorkClassID
        {
            get
            {
                if (!string.IsNullOrEmpty(this.txtWorkClassID.Text.Trim()))
                {
                    return base.GetParamsString(this.txtWorkClassID.Text.Trim(), this.ddlWorkClassIDOper.SelectedValue);
                }
                return "";
            }
        }

        public string WorkType
        {
            get
            {
                if (!string.IsNullOrEmpty(this.ddlWorkType.SelectedValue))
                {
                    return base.GetParamsString(this.ddlWorkType.SelectedValue, this.ddlWorkTypeOper.SelectedValue);
                }
                return "";
            }
        }
    }
}

